package com.ndbg.demo.utils;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Data
@Component
public class RedisMessage {
    @Value("${redis.host}")
    private String host;
    @Value("${redis.port}")
    private String port;
    @Value("${redis.password}")
    private String password;
    @Value("${redis.maxActive}")
    private String maxActive;
    @Value("${redis.maxTotal}")
    private String maxTotal;
    @Value("${redis.maxIdle}")
    private String maxIdle;
    @Value("${redis.maxWaitMillis}")
    private String maxWaitMillis;
    @Value("${redis.poolTimeOut}")
    private String poolTimeOut;


    private static String redisHost;

    private static String redisPort;

    private static String redisPassword;

    private static String redisMaxActive;

    private static String redisMaxTotal;

    private static String redisMaxIdle;

    private static String redisMaxWaitMillis;

    private static String redisPoolTimeOut;


    @PostConstruct
    public void setValue() {
        redisHost = this.getHost();
        redisPort = this.getPort();
        redisMaxIdle = this.getMaxIdle();
        redisMaxTotal = this.getMaxTotal();
        redisMaxActive = this.getMaxActive();
        redisMaxWaitMillis = this.getMaxWaitMillis();
        redisPoolTimeOut = this.getPoolTimeOut();
    }


    public static String getRedisHost() {
        return redisHost;
    }

    public static String getRedisPort() {
        return redisPort;
    }

    public static String getRedisPassword() {
        return redisPassword;
    }

    public static String getRedisMaxActive() {
        return redisMaxActive;
    }

    public static String getRedisMaxTotal() {
        return redisMaxTotal;
    }

    public static String getRedisMaxIdle() {
        return redisMaxIdle;
    }

    public static String getRedisMaxWaitMillis() {
        return redisMaxWaitMillis;
    }

    public static String getRedisPoolTimeOut() {
        return redisPoolTimeOut;
    }
}
